debug.el: Prevent re-entering the debugger for the same error
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 17 Mar 2024 03:10:48 +0000 (23:10 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 17 Mar 2024 03:10:48 +0000 (23:10 -0400)
commit445e2499baa1b8ef21e8edcc13692b5d78912922
tree0be2a8e5971f97a48aad835b8fe96390230670f0
parentad3a3ad6e616a53ec5ae28aed02e8d3461a5ce5c
debug.el: Prevent re-entering the debugger for the same error

We can have several active `handler-bind`s that all want to invoke the
debugger, in which case we can have the following sequence:

- The more deeply nested handler calls the debugger.
- After a while the user invokes `debugger-continue`.
- `signal_or_quit` propagates the error up the stack to the
  second handler, which calls the debugger again.
- The user thus ends up right back at the same place, as if
  `debugger-continue` had not be processed.

Fix this by remembering the last processed error and skipping
the debugger if we bump into it again.

* lisp/emacs-lisp/debug.el (debugger--last-error): New var.
(debugger--duplicate-p): New function.
(debug): Use them.
lisp/emacs-lisp/debug.el